#define _CRT_SECURE_NO_WARNINGS 1

class Solution {
public:
    vector<int> productExceptSelf(vector<int>& nums)
    {
        int n = nums.size();
        vector<int> dp_left(n, 1);
        vector<int> dp_right(n, 1);
        vector<int> ret(n, 1);
        for (int i = 1; i < n; i++)dp_left[i] = dp_left[i - 1] * nums[i - 1];
        for (int i = n - 2; i >= 0; i--)dp_right[i] = dp_right[i + 1] * nums[i + 1];
        for (int i = 0; i < n; i++)ret[i] = dp_left[i] * dp_right[i];
        return ret;
    }
};